<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/" />
	<title>禾米租房 - 首页</title>
	<link type="text/css" rel="stylesheet" href="css/style.css" />
	<script type="text/javascript">
		function toUrl(url){
			window.location.href = url;
			return;
		}
		
		function doSearch(pagenumber){
			currPage.value=pagenumber;	
 			var f = document.getElementById('sform');
			f.submit();
		}
	</script>
	<style>
	  #login a{
	    text-decoration: none;
	  } 
</style>
</head>
<body>
<div id="header" class="wrap">
	<div id="logo"><img src="images/logo.gif" /></div>
	<div id="login" style="text-align: right; margin-top: 10px;">
	<h2>
	<span style="margin-right: 10px;">
	<c:if test="${sessionScope.status!=null}">欢迎用户：</c:if>
	${sessionScope.status==null?"当前没有登录！": sessionScope.status.name}</span>
	<c:if test="${sessionScope.status==null}">
	<a href="dispatcher?target=login">登录</a>
	</c:if>
	</h2>
	<c:if test="${sessionScope.status!=null}">
	 <h3 style="margin-top: 8px;"><a href="user/manage">发布租房信息</a></h3>
	 </c:if>
	</div>
</div>
<div id="navbar" class="wrap">

	<dl class="search clearfix">
		<form method="post" action="home" id='sform'>
		   <input type="hidden"  value="1" name="currPage" id="currPage"/>
			<dt>
				<ul>
					<li class="bold">房屋信息</li>
					<li>
						标题：<input type="text" class="text" value='${requestScope.title }' name="title" />
						<label class="ui-blue"><input type="submit"  name="search" value="搜索房屋" /></label>
					</li>
				</ul>
			</dt>
			<dd>
				<ul>
					<li class="first">
						价格
					</li>
					<li>
						<select name='price'>
							<option value=''>不限</option>
							<c:forEach var="p" items="${requestScope.price }">
							 <option value='${p.key }' ${requestScope.price_id==p.key?"selected":"" }>${p.value }</option>
							</c:forEach>
						</select>
					</li>
				</ul>
			</dd>
			
			<dd>
				<ul>
					<li class="first">房型</li>
					<li>
							<select name='type_id'>
								<option value=''>不限</option>
								<c:forEach var="type" items="${requestScope.type }">
								<option value="${type.id }" ${requestScope.type_id==type.id?"selected":"" }>${type.name }</option>
								</c:forEach>								
							</select>
					</li>
				</ul>
			</dd>
			<dd>
				<ul>
					<li class="first">
						面积
					</li>
					<li>
							<select name='floorage'>
								<option value=''>不限</option>
								<c:forEach var="area" items="${requestScope.area }">
								<option value="${area.key }" ${requestScope.floorage==area.key?"selected":"" }>${area.value}</option>
								</c:forEach>						
							</select>
					</li>
				</ul>
			</dd>
		</form>
	</dl>
</div>
<div class="main wrap">
	<table class="house-list">
	<c:if test="${ !empty requestScope.list.result}">
	<c:forEach var="result" items="${requestScope.list.result}" >
		<tr>
			<td class="house-thumb"><span>
				<a href="details?id=${result.id }"><img src="images/thumb_house.gif" /></a>
			</span>	</td>
			<td>
				<dl>
					<dt>${result.title}</dt>
					<dd>
						${result.distict_name}区
						${result.street_name}，
						${result.floorage}平米<br/>
						联系方式: ${result.contact}
					</dd>
				</dl>
			</td>
			<td class="house-type">${result.type_name}</td>
			<td class="house-price"><span>${result.price}</span>元/月</td>
		</tr>
	</c:forEach>
	</c:if>   
        <c:if test="${empty requestScope.list.result}">
          <tr>
          <td>没有满足该条件的房屋信息</td>
          </tr>
        </c:if>
	</table>
	<c:if test="${ !empty requestScope.list.result}">
	<div class="pager">
		<ul>
			<li class="current">
			<a href="javascript:doSearch(1)">首页</a></li>
			<li>
			<a href='javascript:doSearch(${requestScope.list.prevPage })'>上一页</a></li>
			<li>
			<a href='javascript:doSearch(${requestScope.list.nextPage })'>下一页</a></li>
			<li>
			<a href='javascript:doSearch(${requestScope.list.totalPage})'>末页</a></li>
		</ul>
		<span class="total">${requestScope.list.currPage}/${requestScope.list.totalPage}页</span>
	</div>
	</c:if>
</div>
<div id="footer" class="wrap">
	<dl>
    	<dt>禾米租房 &copy; 2010 禾米教育 浙ICP证1000001号</dt>
        <dd>关于我们 · 联系方式 · 意见反馈 · 帮助中心</dd>
    </dl>
</div>
</body>
</html>